<header class="page-header">
  <nav class="breadcrumb">
    <li>
      <a href="{{href-to 'vault.cluster.policies'}}" data-test-policy-list-link=true>
        <span class="sep">&#x0002f;</span>
        {{uppercase policyType}} Policies
      </a>
    </li>
  </nav>
  <div class="level">
    <div class="level-left">
      <h1 class="title is-3" data-test-policy-name="true">
        {{model.id}}
        {{#if model.enforcementLevel}}
          <span class="tag" aria-label="Enforcement level: {{model.enforcementLevel}}">
            {{model.enforcementLevel}}
          </span>
        {{/if}}
      </h1>
    </div>
  </div>
</header>
<div class="box is-bottomless is-fullwidth is-marginless">
  <div class="level is-mobile">
    <div class="level-left">
      <label for="policy" class="is-label">Policy</label>
      {{#if (eq policyType "acl")}}
      <span class="tag is-white is-size-9" data-test-acl-format>({{uppercase model.format}} format)</span>
      {{/if}}
    </div>
    <div class="level-right">
      <div class="field is-horizontal is-flex-end is-single-line">
        {{#if (and (not-eq model.id "root") (or capabilities.canUpdate capabilities.canDelete))}}
          <div class="control is-flex">
            {{input
              id="edit"
              type="checkbox"
              name="navToEdit"
              class="switch is-rounded is-success is-small"
              checked=false
              change=(action (nav-to-route 'vault.cluster.policy.edit' model.id replace=true) )
              data-test-policy-edit-toggle=true
            }}
            <label for="edit">Edit</label>
          </div>
        {{/if}}
      </div>
    </div>
  </div>
  <div class="field">
    {{ivy-codemirror
      value=model.policy
      options=(hash
        readOnly=true
        lineNumbers=true
        tabSize=2
        mode='ruby'
        theme='hashi'
      )
    }}
  </div>
  {{#if model.paths}}
    <div class="field box is-shadowless no-bottom-padding is-marginless">
      <h2 class="title is-6">Paths</h2>
      <ul data-test-egp-paths>
        {{#each model.paths as |path|}}
          <li class="box has-slim-padding no-top-shadow is-marginless">
            <code class="has-text-black">{{path}}</code>
          </li>
        {{/each}}
      </ul>
    </div>
  {{/if}}
  <div class="field box is-shadowless no-bottom-padding is-marginless">
    {{download-button
      classNames="link is-pulled-right"
      actionText="Download policy"
      extension=(if (eq policyType "acl") model.format "sentinel")
      filename=model.name
      data=model.policy
    }}
  </div>
</div>
